package com.shuai.adapter;

import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;

import com.shuai.stickynote.MemoryNote;
import com.shuai.stickynote.R;

import java.util.ArrayList;

public class MemoryRemoteViewFactory implements RemoteViewsService.RemoteViewsFactory {
    private Context context;
    public static ArrayList<MemoryNote> memorys = new ArrayList<>();
    private String TAG = "fuck";

    public MemoryRemoteViewFactory(Context context, Intent intent) {
        this.context = context;
    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onDataSetChanged() {

    }

    @Override
    public void onDestroy() {
        memorys.clear();
    }

    @Override
    public int getCount() {
        return memorys.size();
    }

    @Override
    public RemoteViews getViewAt(int position) {
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.adapter_widget_memory_list_item);
        views.setTextViewText(R.id.adapter_widget_memory_en,memorys.get(position).getEn());
        views.setTextViewText(R.id.adapter_widget_memory_ch,memorys.get(position).getCh());
        return views;
    }

    @Override
    public RemoteViews getLoadingView() {
        return null;
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }
}
